//
//  PSLeningradCalculator.m
//  PrefCore
//
//  Created by Sergey on 2/27/14.
//  Copyright (c) 2014 Play-on-smart. All rights reserved.
//

#import "PSLeningradCalculator.h"

@implementation PSLeningradCalculator

-(instancetype)init {
    if (self = [super initWithPassingScorer:[PSScorer passingScorer]
                           costsPlaySuccess:@[@2, @4,  @6,  @8, @10]
                              costsPlayFail:@[@4, @8, @12, @16, @20]
                          costsWhistSuccess:@[@4, @8, @12, @16, @20]
                             costsWhistFail:@[@2, @4,  @6,  @8, @10]
                        normalizationFactor:2]) {
    }
    return self;
}

-(BOOL)isClosed:(PSPlayer*)p game:(PSGame*)game settings:(PSGameSettings*)settings {
    // Once the game is over, everyone is closed
    return [self isGameOver:game settings:settings];
}

-(BOOL)isGameOver:(PSGame*)game settings:(PSGameSettings*)settings {
    PSScoreValue pool = 0;
    for (PSPlayer *p in game.players) {
        pool += [game scoreForPlayerId:p.identifier].pool.current;
    }
    return pool >= settings.poolSize * PS_GAME_PLAYERS;
}

@end
